<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

//for top menu
function admin_page_url($slug = null, $params=null) {
	$str = '';
	$url = '';
	if($params!=null){
		$str = http_build_query($params);
	}
	if ($slug == null) {
		$url = base_url(ADMIN_FOLDER) . config_item('url_suffix');
	} else {
		$url = base_url(ADMIN_FOLDER . $slug) . config_item('url_suffix');
	}
	if($str!=''){
		return $url.'?'.$str;
	}
	return $url;
}
//for top menu
function mns_page_url($slug = null, $params=array()) {
	$get = "";
	if(count($params)>0){
		$get = '?'.http_build_query($params);
	}
	if ($slug == null) {
		return base_url(SHOP_FOLDER) . config_item('url_suffix').$get;
	}
	return base_url(SHOP_FOLDER . $slug) . config_item('url_suffix').$get;
}

// for contact menu
function contact_paging_url($folder){
	return base_url($folder . CONTACT_SLUG . '/trang');
}

function page_url($slug = null, $param=array()){
	if ($slug == null) {
		return base_url();
	}
	if(count($param)>0){
		return base_url($slug) . config_item('url_suffix') . '?' . http_build_query($param);
	}
	return base_url($slug) . config_item('url_suffix');
}
function category_url($slug){
	return base_url('c/' . $slug) . config_item('url_suffix');
}
function product_url($slug, $code=null){
	if($code!=null){
		return base_url('p/' . $slug) . config_item('url_suffix') . '?code=' . $code;
	}
	return base_url('p/' . $slug) . config_item('url_suffix');
}
function product_paging_url(){
	return base_url(PRODUCT_SLUG . '/trang');
}
function shop_url($slug, $page=null){
	$q = $_SERVER['QUERY_STRING']!=''?'?'.$_SERVER['QUERY_STRING']:'';
	if($page!=null){
		return base_url('s/' . $slug . '/' . $page) . config_item('url_suffix') . $q;
	}
	return base_url('s/' . $slug) . config_item('url_suffix') . $q;
}
function shop_paging_url(){
	return base_url(SHOP_SLUG_NEW . '/trang');
}
function shop_cate_paging_url($cate){
	return base_url(SHOP_SLUG_NEW . '/c/' . $cate . '/trang');
}
function post_url(){
	return base_url(POST_SLUG . '/trang');
}
function post_paging_url($pageIndex){
	return base_url(POST_SLUG . '/trang-'.$pageIndex).config_item('url_suffix');
}
function post_single_url($slug){
	return base_url(POST_SLUG . '/' . $slug) . config_item('url_suffix');
}
function post_cate_url($slug){
	return base_url(POST_SLUG . '/c/' . $slug) . config_item('url_suffix');
}
function post_page_by_cate_url($slug){
	return base_url(POST_SLUG."/c/{$slug}/trang");
}
function search_paging_url(){
	return base_url('tim-kiem/trang');
}
function sale_url() {
	return base_url(SALE_SLUG . '/trang');
}
function rao_vat_page_url() {
	return base_url(RAOVAT_SLUG.'/trang');
}
function rao_vat_single_url($slug) {
	return base_url(RAOVAT_SLUG.'/'.$slug) . config_item('url_suffix');;
}
function rao_vat_cate_url($slug){
	return base_url(RAOVAT_SLUG.'/c/'.$slug) . config_item('url_suffix');;
}
function rao_vat_page_by_cate_url($slug) {
	return base_url(RAOVAT_SLUG."/c/{$slug}/trang");
}
function shop_product_url($shop_slug, $product_slug) {
	$q = $_SERVER['QUERY_STRING']!=''?'?'.$_SERVER['QUERY_STRING']:'';
	return base_url('s/' . $shop_slug . '/' . PRODUCT_SLUG . '/' . $product_slug) . config_item('url_suffix') . $q;
}
function shop_cate_url($shop_slug, $slug) {
	return base_url('s/' . $shop_slug . '/' . $slug) . config_item('url_suffix');
}
function shop_product_paging_url($shop_slug) {
	return base_url('s/' . $shop_slug . '/trang');
}
function shop_product_page_paging_url($shop_slug) {
	return base_url('s/' . $shop_slug . '/' . PRODUCT_SLUG . '/trang');
}
function shop_product_search_paging_url($shop_slug) {
	return base_url('s/' . $shop_slug . '/tim-kiem/trang');
}
?>